﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TireSizesCalculator.Model
{

    public class RimsSize
    {
        private bool _loaded = false;
       private string _sizeRim;
       private string _sizeRimMin;
       private string _sizeRimMax;
       private Model.TireSize ts;
       private int _tireSize;
       private String infoRecommendedRimSize;
       private String infoMinRimSize;
       private String infoMaxRimSize;


       public RimsSize(TireSize tire)
       {
           ts = tire;
       }

       public string MinRimSize
       {
           get
           {
               if (!_loaded)
               {
                   lookForASuitableRims();
               }

               return _sizeRimMin +" J x "+ts.Radius;
           }
       }

       public string RimSize
       {
           get
           {
               if (!_loaded)
               {
                   lookForASuitableRims();
               }

               return _sizeRim + " J x " + ts.Radius;
           }
       }

       public string RimSizeMax
       {
           get
           {
               if (!_loaded)
               {
                   lookForASuitableRims();
               }

               return _sizeRimMax + " J x " + ts.Radius;
           }
       }
        private void lookForASuitableRims()
        {
            _tireSize = ts.Width;

            switch (_tireSize)
            {
                case 135: _sizeRim = "4"; _sizeRimMin = "3.5"; _sizeRimMax = "4.5"; break;
                case 145: _sizeRim = "4.5"; _sizeRimMin = "3.5"; _sizeRimMax = "5"; break;
                case 155: _sizeRim = "4.5"; _sizeRimMin = "4"; _sizeRimMax = "5.5"; break;
                case 165: _sizeRim = "5"; _sizeRimMin = "4.5"; _sizeRimMax = "6"; break;
                case 175: _sizeRim = "5"; _sizeRimMin = "4.5"; _sizeRimMax = "6"; break;
                case 185: _sizeRim = "5.5"; _sizeRimMin = "5"; _sizeRimMax = "6.5"; break;
                case 195: _sizeRim = "6"; _sizeRimMin = "5.5"; _sizeRimMax = "7"; break;
                case 205: _sizeRim = "6.5"; _sizeRimMin = "5.5"; _sizeRimMax = "7"; break;
                case 215: _sizeRim = "7-7.5"; _sizeRimMin = "6"; _sizeRimMax = "8"; break;
                case 225: _sizeRim = "7-7.5"; _sizeRimMin = "6"; _sizeRimMax = "8.5"; break;
                case 235: _sizeRim = "7-8"; _sizeRimMin = "6.5"; _sizeRimMax = "9.5"; break;
                case 245: _sizeRim = "8-8.5"; _sizeRimMin = "7"; _sizeRimMax = "9.5"; break;
                default: _sizeRimMin = _sizeRim = _sizeRimMax = "0"; break;
            }

            infoRecommendedRimSize = _sizeRim + "J x " + ts.Radius;
            infoMinRimSize = _sizeRimMin + "J x " + ts.Radius;
            infoMaxRimSize = _sizeRimMax + "J x " + ts.Radius;
            _loaded = true;
        }
    }
}
